﻿#ifndef STATISTICS_H
#define STATISTICS_H

#include <head/g_pch.h>
#include "m_fhs.h"

#define NAME_COL 0
#define ORDER_COL 1
#define RANK_COL 2

namespace Ui {
class Statistics;
}

class Statistics : public QDialog
{
    Q_OBJECT

public:
    explicit Statistics(QWidget *parent,
                        const QString &month,
                        const QStringList &publishers);
    ~Statistics();

    void updateHistory();
    void updateView(const QString &month);
    void do_order();
    void do_rank();
    void do_stat();
    bool insertItem(const QString &id_,
                    const QString &name,
                    const QString &p_submit,
                    const QString &p_rank);

    bool updateItem(const QString &id_,
                    const QString &p_submit,
                    const QString &p_rank);

private slots:
    void on_btn_generate_clicked();
    void on_btn_save_clicked();
    void on_listView_doubleClicked(const QModelIndex &index);

private:
    Ui::Statistics *ui;

    QString table;
    QString index_table;
    QString currentMonth;
    QStringList _publishers;
    bool updateFlag;
    QStandardItemModel *model;
    QStringListModel *listModel;
};

#endif // STATISTICS_H
